package com.hmall.search.web;


import com.hmall.common.client.ItemClient;
import com.hmall.common.dto.ItemDoc;
import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.IsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author Azer
 * @LOVE,,,
 * @Date 2021/11/8 8:23
 */
@RestController
@RequestMapping("search")
public class SearchController {
    @Autowired
    private IsearchService searchService;



    //自动补全
    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam(value = "key") String key){
        return searchService.suggestion(key);

    }

    //过滤聚合功能
    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody RequestParams params){
        return searchService.filters(params);

    }

    //搜索
    @PostMapping("/list")
    public PageDTO<ItemDoc> query(@RequestBody RequestParams params){

        return searchService.search(params);
    }


}
